Skip to content

Issue #50: HTTP errors are ignored and result in empty responses with…#55

Closed
tdltdl wants to merge 1 commit intoipinfo:masterfrom
tdltdl:bugfix/issue-50-http-errors-ignored
Closed

Issue #50: HTTP errors are ignored and result in empty responses with…#55
tdltdl wants to merge 1 commit intoipinfo:masterfrom
tdltdl:bugfix/issue-50-http-errors-ignored

Conversation

@tdltdl
Copy link

@tdltdl tdltdl commented Sep 11, 2024

… cache poisoning.

WARNING This change is not a drop in replacement as if we get 403 because the token is incorrect, a checked exception is raised.

Also note that, if an empty or null token is passed, it is now a fail fast (instead of getting a null pointer exception at the first request)

…s with cache poisoning.

WARNING This change is not a drop in replacement as if we get 403 because the token is incorrect, a checked exception is raised.
Also note that, if an empty or null token is passed, it is now a fail fast (instead of getting a null pointer exception at the first request)
Copy link
Contributor

@max-ipinfo max-ipinfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdltdl thanks for sending your PR. I will continue to bring timely feedback from now on so we can create new package versions after each PR.

Please go over the exception restructuring suggested, with all HTTP exceptions inheriting from HttpErrorException. That includes simplifying all throws clauses to throws HttpErrorException where it makes sense.

Could you also update README.md' s Error section and document the new errors hierarchically?

I'll help you update the documentation for every exception after your next change.

@@ -374,6 +375,9 @@ public Builder setCache(Cache cache) {
}

public IPinfo build() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this have throws IllegalArgumentException?

* <p>That likely indicates that the token is either missing, incorrect or expired.
* It is a checked exception so, if you have multiple tokens (example during transition), you can fall back to another token.</p>
*/
public class InvalidTokenException extends Exception {
Copy link
Contributor

@max-ipinfo max-ipinfo Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we've introduced a proper HttpErrorException class, we should have InvalidTokenException and RateLimitedException also inherit from it, as they are technically exceptions stemming from an HTTP error response.

This helps simplify the design (no need to disambiguate everywhere with throws RateLimitedException, InvalidTokenException ) and it also helps clarify (in code) that they stem from the same source.

}

public abstract T handle() throws RateLimitedException;
public abstract T handle() throws RateLimitedException, InvalidTokenException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to throws HttpErrorException

public abstract T handle() throws RateLimitedException, InvalidTokenException;

public Response handleRequest(Request.Builder request) throws RateLimitedException {
public Response handleRequest(Request.Builder request) throws RateLimitedException, InvalidTokenException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this can be simplified throws HttpErrorException

@tdltdl
Copy link
Author

tdltdl commented Feb 17, 2026

Why has this PR been closed without merge? This leads to cache poisoning...

@max-ipinfo
Copy link
Contributor

@tdltdl this PR has been stale for a very long time and the comments have not been addressed.

I'll let @silvanocerza decide if he wants to revive this PR.

Thanks for your understanding.

@tdltdl
Copy link
Author

tdltdl commented Feb 17, 2026

In this case the maintainer didn't act on it for a long time. I am a bit surprised you want your Cust to have their cache poisoned with incorrect data. It also appears that strongly type exception to make API explicit and help Cus t know what they need to handle is not a design goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments